Ext.namespace("SysMgr");

SysMgr.TreeLoader=Ext.extend(Ext.tree.TreeLoader,{
	processResponse : function(response, node, callback, scope){
        var json = response.responseText;
        try {
            var o = response.responseData || Ext.decode(json);            
            o=o.result;            
            node.beginUpdate();
            for(var i = 0, len = o.length; i < len; i++){
            	if(o[i].leaf=="true")
            		o[i].leaf=true;
            	else
            		o[i].leaf=false;
            	if(o[i].expandable=="true")
            		o[i].expandable=true;
            	else
            		o[i].expandable=false;
            	if(o[i].expanded=="true")
            		o[i].expanded=true;
            	else
            		o[i].expanded=false;
                var n = this.createNode(o[i]);                
                if(n){
                    node.appendChild(n);
                }
            }
            node.endUpdate();
            this.runCallback(callback, scope || node, [node]);
        }catch(e){
            this.handleFailure(response);
        }
    }
});
SysMgr.CheckLoader=Ext.extend(Ext.tree.TreeLoader,{
	processResponse : function(response, node, callback, scope){
        var json = response.responseText;
        try {
            var o = response.responseData || Ext.decode(json);            
            o=o.result;            
            node.beginUpdate();
            for(var i = 0, len = o.length; i < len; i++){
            	if(o[i].checked=="true")
            		o[i].checked=true;
            	else
            		o[i].checked=false;
            	if(o[i].leaf=="true")
            		o[i].leaf=true;
            	else
            		o[i].leaf=false;
            	if(o[i].expandable=="true")
            		o[i].expandable=true;
            	else
            		o[i].expandable=false;
            	if(o[i].expanded=="true")
            		o[i].expanded=true;
            	else
            		o[i].expanded=false;
                var n = this.createNode(o[i]);                
                if(n){
                    node.appendChild(n);
                }
            }
            node.endUpdate();
            this.runCallback(callback, scope || node, [node]);
        }catch(e){
            this.handleFailure(response);
        }
    }
});